package web.servlet.list.web;


import web.servlet.list.dao.UserDao;
import web.servlet.list.dao.UserDaoImpl;
import web.servlet.list.domin.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * @Author: 18148
 * @Date: 2020-06-12 22:12:02
 */
@WebServlet("/findUserServlet")
public class FindUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String ids = req.getParameter("id");
        int id = Integer.parseInt(ids);
        UserDao dao = new UserDaoImpl();
        User user = dao.findById(id);
        req.setAttribute("user", user);
        req.getRequestDispatcher("/list/update.jsp").forward(req, resp);
    }
}
